$(function () {
    let data = {
        pagenum: 1,
        pagesize: 6
    }
    let total;
    let arr = [`<div class="kr_news_date">17 <span>08月</span></div>`]

    function getarticle() {
        if (arr.length >= total) {
            return layer.msg('没有更多数据了')
        }
        $.ajax({
            type: "get",
            url: "http://localhost:8888/api/articles",
            data,
            success: function (res) {
                if (res.status === 0) {
                    total = res.total;
                    $(".kr_news_list").empty();
                    res.data.forEach(function (item) {
                        arr.push(`
                          <div class="item">
                            <h4>
                              <a href="./detail.html?id=${item.id}">${item.title}</a>
                            </h4>
                            <p class="meta">
                              <span>19分钟前 分享至</span>
                              <a href="javascript:;" class="wechat"></a>
                              <a href="javascript:;" class="weibo"></a>
                            </p>
                            <p class="brief">${item.content}</p>
                          </div>
                        `)
                    })
                    console.log(arr);
                    $('.kr_news_list').append(arr.join(''))
                }
            }
        })
    }
    getarticle();
    $(".kr_more").on("click", function () {
        data.pagenum += 1;
        getarticle();
    })
})